package cn.edu.hunau.oop.day01;

import org.junit.Test;

import java.util.Arrays;

/**
 * @author hb
 * @date 2025-08-04 14:42:12
 */
public class TwoArrayTest {

    @Test
    public void init02(){
        int[][] arr=new int[][]{{10,11},{20,21,22},{30,31,32,33}};
        print(arr);
        int[][] arr2= {{10,11},{20,21,22},{30,31,32,33}};
        print(arr2);

    }

    public void print(int[][] array){
        for(int rows=0;rows<array.length;rows++){
            for(int cols=0;cols<array[rows].length;cols++){
                System.out.print(array[rows][cols]+"\t");
            }
            System.out.println();
        }
    }


    @Test
    public void initArray(){
        int[][] array=new int[3][];
        array[0]=new int[2];
        array[1]=new int[3];
        array[2]=new int[4];

        for(int rows=0;rows<array.length;rows++){
           for(int cols=0;cols<array[rows].length;cols++){
                array[rows][cols]=rows*cols;
                System.out.print(rows*cols+"\t");
           }
           System.out.println();
        }
    }
}
